package com.ogilvy.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ogilvy.cms.bean.CmsTemplateField;
import com.ogilvy.cms.dao.CmsTemplateFieldDao;
import com.ogilvy.cms.service.CmsTemplateFieldService;
import com.ogilvy.frame.service.BaseServiceImpl;
@Service
public class CmsTemplateFieldServiceImpl extends BaseServiceImpl implements CmsTemplateFieldService{
	@Autowired
	protected CmsTemplateFieldDao CmsTemplateFieldDao;
	public CmsTemplateField add(CmsTemplateField temField) {
		// TODO Auto-generated method stub
		CmsTemplateField ctf=CmsTemplateFieldDao.save(temField);
		return ctf;
	}

	public boolean del(int ctfId) {
		// TODO Auto-generated method stub
		CmsTemplateFieldDao.deleteById(ctfId);
		return true;
	}

	public boolean modify(CmsTemplateField temField) {
		// TODO Auto-generated method stub
		CmsTemplateFieldDao.update(temField);
		return true;
	}

	public List<CmsTemplateField> query(CmsTemplateField temField) {
		// TODO Auto-generated method stub
		if(isEmpty(temField.getCtfId())){
			return CmsTemplateFieldDao.findAll();
		}
		return CmsTemplateFieldDao.findByProperty("ctfId",temField.getCtfId());
	}

	public List<CmsTemplateField> findById(CmsTemplateField temField) {
		// TODO Auto-generated method stub
		return CmsTemplateFieldDao.findByProperty("fieldid",temField.getCtfId());
	}

	public List<CmsTemplateField> findAll(CmsTemplateField temField) {
		// TODO Auto-generated method stub
		return CmsTemplateFieldDao.findAll();
	}

	public List<CmsTemplateField> findAllList() {
		// TODO Auto-generated method stub
		return CmsTemplateFieldDao.findAll();
	}

	public List<CmsTemplateField> queryByScreen(Map<String, String> screenMap) {
		// TODO Auto-generated method stub
		return CmsTemplateFieldDao.getListByScreen(screenMap);
	}

	public boolean checkTempFieldName(String ctfName) {
		return CmsTemplateFieldDao.isHaveName(ctfName);
	}

	public List<CmsTemplateField> selectTemplateFieldByCmtId(int cmtId) {
		return CmsTemplateFieldDao.selectTemplateFieldByCmtId(cmtId);
	}

}
